#@layout() #define head()
<style type="text/css">
form {
	margin: 5px 10px;
}
</style>
<script type="text/javascript">
	var cookie_login_signup_key = '_auto_remember_key_';
	var cookie_login_userid_key = '_auto_userid_key_';
	var cookie_login_userpwd_key = '_auto_userpwd_key_';
	var cookie_valid_time=30;
	
	$(document).ready(function() {
		$("body").addClass("hold-transition login-page");
		 //回车提交事件
		$("body").keydown(function() {
		  if (event.keyCode == "13") {//keyCode=13是回车键
		    $("#submitBtn").click();
		  }
		}); 
		waitLoading(false);
		var myform=$("form");
		if(_.isEmpty($("#username").val())){
			var uname =$.cookie("get", { name: cookie_login_userid_key }); 
			if (!_.isEmpty(uname)){
				$("#username").val(uname);
			}
		}
		if($.cookie("get", { name: cookie_login_signup_key })=="true"){
			$('#signup').prop("checked",true);
			var pwd = $.cookie("get", { name: cookie_login_userpwd_key });
			if (pwd) {
				$("#pwd").val(pwd);
			}
		}
		
		new autoEventListener(myform,false).initFormValidator();
		
		myform.bootstrapValidator({
			fields: {
		        username: {
			        validators: {
			            notEmpty: {
			            	message: "用户名不能为空"  
			            },
	                    stringLength: {
	                        min: 2,
	                        max: 16,
	                        message: "用户名为2-16个字符"
	                    }
			        }
		        },
		        pwd: {
			        validators: {
			            notEmpty: {
			            	message: "登录密码不能为空"  
			            },
	                    stringLength: {
	                        min: 6,
	                        max: 16,
	                        message: "登录密码为6-16个字符"
	                    }
			        }
		        },captcha: {
			        validators: {
			            notEmpty: {
			            	message: "验证码不能为空"  
			            },
	                    stringLength: {
	                        min: 4,
	                        max: 4,
	                        message: "验证码为4个字符"
	                    }
			        }
		        }
			}
		});
		
		#if(null != error)
			showMsg("#(error)","error");
		#end	
		myform.find("input").keypress(function(e) {
            if (e.which == 13) {
            	$("#submitBtn").trigger("click");
                return false;  
            }  
        });
		
		
		$('.particleground').particleground({
			dotColor : '#0993d3',
			lineColor : '#0993d3'
		});
		
		$(".totop").click(function(){
			_addSysFeedback();
		});
	});
	
	function do_singup(){
		var signup=$('#signup').prop("checked");
		if (signup) {
			$.cookie("set", { name: cookie_login_userpwd_key, value: $("#pwd").val(),duration: cookie_valid_time});
		} else {
			$.cookie("delete", { name: cookie_login_userpwd_key});
		}
		$.cookie("set", { name: cookie_login_userid_key, value: $("#username").val(),duration: cookie_valid_time});
		$.cookie("set", { name: cookie_login_signup_key, value: signup,duration: cookie_valid_time});
		return true;
	}
</script>
#end #define body()
<div class="login-box">
  <div class="login-logo">
    <i class="fa fa-coffee"></i> <b>#(SYS_NAME)</b>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">

	<form action="login"  method="post" role="form" class="form-horizontal" onsubmit="do_singup();">
		<div class="form-group">
			<div class="input-group">
			<span class="input-group-addon"><i class="fa fa-user"></i></span>
			<input id="username" name="username" value="#(username)" type="input" class="form-control" placeholder="用户名" maxlength="16"> 
			</div>	
		</div>
		<div class="form-group">
			<div class="input-group">
			<span class="input-group-addon"><i class="fa fa-asterisk"></i></span>
			<input id="pwd" name="pwd" type="password" class="form-control" placeholder="密　码" maxlength="16">
			</div>	
		</div>
		<div class="form-group">
			<div class="col-md-8"  style="padding-left: 0px;">
				<div class="input-group">
				<span class="input-group-addon"><i class="fa fa-image"></i></span>
				<input id="captcha" name="captcha" value="1234" type="input" class="form-control" placeholder="验证码" maxlength="4" >
				</div>	
			</div>
			<div class="col-md-4" style="padding-left: 0px;">
				<img src="captcha" style="height: 34px;">
			</div>
		</div>
		<div class="form-group">
			<div class="col-lg-9">
				<div class="checkbox checkbox-warning">
                    <input id="signup" name="signup"  value="true"  type="checkbox" class="success">
					<label for="signup" class="checked">记住密码</label>
				</div>
			</div>
		</div>
		<div class="col-lg-8 col-lg-offset-4">
			<button id="submitBtn" type="submit" class="btn btn-danger" ><i class="btn-label fa fa-check-circle"></i>&nbsp;&nbsp;登录</button>
			&nbsp;&nbsp;
			<button type="reset" class="btn btn-danger"><i class="btn-label fa fa-refresh"></i>&nbsp;&nbsp;重置</button>
		</div>
		<br>
	</form>
	<span class="totop auto-btn auto-dialog" title="系统反馈"><a href="javascript:void(9);"><i class="fa fa-handshake-o"></i></a></span>
  </div>
  <!-- /.login-box-body -->
</div>
<div class="particleground"></div>
#end
